home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Discover the Great Lakes
/
Discover the Great Lakes.iso
/
quiz-script.txt
< prev
next >
Wrap
Text File
|
1997-10-09
|
12KB
|
379 lines
Toolbook Scripts for Generic Quiz
| Book | Background | Results Page | Certificate Page |
Book Scripts
to handle enterBook
system recentUser,qTries
put "FALSE" into recentUser
put 0 into qTries
end enterBook
--------------------------------
-- general navigation scripts
--------------------------------
to handle doQuit
system theUser
-- called by quit button
beep 1
request word 1 of theUser & ", do you want to quit from the"\
&& quote & "Orient Express" & quote && "?" with "no" or\
"yes"
if (it is "yes") then; send exit; end if
end doQuit
---------------------------------------------------------------------------
| Book | Background | Results Page | Certificate Page |
Background Scripts
These scripts are available to every card that uses the quiz background
to handle enterPage
-- set up quiz card
system qPointer,qMax,firstTry
-- VARIABLES:
-- qPointer: current quiz number
-- qMax: total number of questions
-- firstTry: =0 if user has not tried at least once
-- update card counter
put qPointer && "of" && qMax into text of recordField "count"
set sysLockScreen to true
-- show answer fields
send ansVis TRUE
-- reset try flag
put 0 into firstTry
-- randomly sort the list of answers
put scrambleItems(4) of this book into fList
-- reset the location of answer fields
step i from 1 to 4
get "ans" && item i of fList
set the position of recordField it to 430,1200 + i * 900
set the position of button it of this background to 345, 1110 + i * 900
end step
-- hide NEXT button until user tries once
hide button "next" of this background
set sysLockScreen to false
end enterPage
to handle leavePage
-- clean up card
system reviewList
send hideHilite
send hideFb
send ansVis false
if the visible of recordField "help" then
send showHelp FALSE
end if
end leavePage
to handle ansVis state
-- toggles visibility of answer fields
step i from 1 to 4
set the visible of recordField ("ans" && i) to state
end step
end ansVis
to handle checkAnswer
-- compare users response and show correct feedback
system firstTry,qScore,reviewList
-- exit if user clicked on last resposne
if the invert of button (name of the target) of this background then;
break checkAnswer
end if
-- hilite the button
send hideHilite
set the invert of button (name of the target) of this background to true
set sysLockScreen to true
-- hide all feedback fields
send hideFB
-- get name of selected answer and show feeback
get word 2 of the name of the target
show recordField ("fb" && it)
-- score if this was first try
if firstTry = 0 then;
-- enable NEXT button
show button "next" of this background
-- check answer with name of current card
if it=character 3 of the name of this page then;
increment qScore by 1
else
put text of recordField "topic" & crlf after reviewList
end if
put 1 into firstTry
end if
set sysLockScreen to false
end checkAnswer
to handle hideHilite
-- turn off all button hilites and reset left of answer fields
set sysLockScreen to true
step i from 1 to 4
set the invert of button ("ans" && i) of this background to FALSE
end step
set sysLockScreen to false
end hideHilite
to handle hideFB
-- hide all feedback fields
step i from 1 to 4
hide recordField ("fb" && i)
end step
end hideFB
to handle setAnswer
-- flash the text of the field back field and reset the correct answer
set the name of this page to "qz" & word 2 of the name of the target
step ht_1 from 1 to 4
select textLines 1 to 5 of the target
pause 15 ticks
select null
end step
end setAnswer
to handle showHelp state
-- show help field
set the sysLockScreen to true
put the objects of this page into objList
step i from 1 to itemCount(objList)
set the visible of item i of objList to NOT state
end step
set the visible of recordField "help" to state
set the sysLockScreen to FALSE
end showHelp
--------------------------------
-- quiz card scripts
--------------------------------
to handle setUpQuiz
system qList,qPointer,qMax,qScore,reviewList,qTries
-- qList: item list of the question cards
-- qPointer: item number of current question
-- qMax: total number of questions
-- reviewList: names of missed questions
-- qTries: number of quiz attempts
hide button "self-test" of this background
show button "topics" of this background
-- initialize variables for quiz section
put the pageCount of background "quiz" into qMax
put scrambleItems(qMax) into qList
put 0 into qPointer
put 0 into qScore
increment qTries by 1
put null into reviewList
end setUpQuiz
to handle nextQuiz
-- advance to next quiz question
-- qPointer: current quiz question
-- qMax: total number of quiz questions
-- qList: item list of quiz questions
system qPointer,qMax,qList
if qPointer = qMax then;
-- if this was last quiz, go to finish screen
go page "done quiz"
else
-- go to quiz card
increment qPointer by 1
go page (item qPointer of qList) of background "quiz"
end if
end nextQuiz
to get scrambleItems nItems
-- randomly scrambles list of numbers from 1 to nItems
put null into theList
step i from 1 to nItems
push i onto theList
end step
step ht_1 from 1 to nItems
-- random by swapping items in list
put random (nItems) into firstOne
put random (nItems) into secondOne
put item firstOne of theList into temp
put item secondOne of theList into item firstOne of theList
put temp into item secondOne of theList
end step
return theList
end scrambleItems
---------------------------------------------------------------------------
| Book | Background | Results Page | Certificate Page |
Results Page
to handle enterPage
send displayResults
end enterPage
to handle leavePage
put null into text of field "results"
end leavePage
to handle displayResults
-- calculate quiz scores
system qMax,qScore,reviewList,theUser
-- VARIABLES
-- qMax: total number of questions
-- qScore: number correct on first answer
-- reviewList list of missed questions by topic name
-- precentage needed to pass
put 80 into passingScore
set sysLockScreen to true
hide button "self-test" of this background
show button "topics" of this background
-- calculate score
put (qScore / qMax * 100) div 1 into userScore
put "You scored" && qScore && "correct on the first try"\
&& "out of a total of" && qMax && "questions, or" \
&& userScore & "%." & crlf & crlf into text of field "results"
if (userScore >= passingScore) then;
-- user passed minimum
set the borderStyle of field "results" to rectangle
-- show button "certificate" of this page
hide button "redo" of this page
show button "next" of this page
put "Since you exceeded " & passingScore & "%, you have passed the requirements"\
&& "for this section of the Orient Express."\
& crlf & crlf & crlf\
& "CONGRATULATIONS," && word 1 of theUser && "!" & crlf & crlf\
& "Click on the arrow button to receive your Orient Express certificate."\
after text of field "results"
set the fontStyle of textline 6 of the text of field "results" to bold